﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<div class="modal-dialog x-modal-dialog" style="width: 600px;margin-top: 150px;">

  <div class="modal-content">

    <div class="modal-header x-breadcrumb clearfix">

      <h2><i class="glyphicon glyphicon-fire" title=""></i>&nbsp;&nbsp;<span>编辑课程预约时间</span></h2>

      <button type="button" class="close" data-dismiss="modal">&times;</button>

    </div>

    <form class="form-horizontal" method="POST" action="${ctx.host}/courses/${course.id}/appoint-time" data-validate="true">

      <input type="hidden" name="_method" value="PATCH" >
      <input type="hidden" name="courseId" value="${course.id}" >

      <div class="modal-body">
      
        <div class="form-group x-form-group">
          <label class="col-xs-3 control-label">预约开始时间：</label>
          <div class="pull-left col-xs-8">
            <select name="appointStartTime" class="form-control"  aria-describedby="basic-addon2" data-validate="required">
              <option></option>
              <c:forEach begin="0" end="24" varStatus="status">
                <c:set var="hour" value="${status.index}:00"></c:set>
                <c:set var="halfhour" value="${status.index}:30"></c:set>
                <option value="${hour}" ${course.appointStartTime eq hour ? 'selected' : ''}>${status.index}:00</option>
                <c:if test="${status.index != 24}">
                  <option value="${halfhour}" ${course.appointStartTime eq halfhour ? 'selected' : ''}>${status.index}:30</option>
                </c:if>
              </c:forEach>
             </select>
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="col-xs-3 control-label">预约结束时间：</label>
          <div class="pull-left col-xs-8">
            <select name="appointEndTime" class="form-control"  aria-describedby="basic-addon2" data-validate="required">
              <option></option>
              <c:forEach begin="0" end="24" varStatus="status">
                <c:set var="hour" value="${status.index}:00"></c:set>
                <c:set var="halfhour" value="${status.index}:30"></c:set>
                <option value="${hour}" ${course.appointEndTime eq hour ? 'selected' : ''}>${status.index}:00</option>
                <c:if test="${status.index != 24}">
                  <option value="${halfhour}" ${course.appointEndTime eq halfhour ? 'selected' : ''}>${status.index}:30</option>
                </c:if>
              </c:forEach>
             </select>
          </div>
        </div>
        
        <div class="modal-footer">
          <button type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;
          <button type="button" class="btn btn-default btn-shadow btn-shadow-default x-btn" data-dismiss="modal">取消</button>
        </div>
        
      </div>
      
    </form>
  </div>
</div>

<script>
$(function(){
	 $('select[name="appointStartTime"], select[name="appointEndTime"]').select2({
	      placeholder : '请选择预约时间',
	      minimumResultsForSearch : 5,
	      allowClear : true
	    });
})
</script>

